<?php
// +-----------------+------------------------------------------+------+-----+---------+----------------+
// | Field           | Type                                     | Null | Key | Default | Extra          |
// +-----------------+------------------------------------------+------+-----+---------+----------------+
// | id              | int(11)                                  | NO   | PRI | NULL    | auto_increment |
// | name            | varchar(50)                              | NO   |     |         |                |
// | password        | varchar(64)                              | NO   |     |         |                |
// | nickname        | varchar(50)                              | YES  |     |         |                |
// | mobile          | varchar(15)                              | YES  | MUL |         |                |
// | email           | varchar(100)                             | YES  |     |         |                |
// | url             | varchar(255)                             | YES  |     |         |                |
// | avatar          | varchar(255)                             | YES  |     |         |                |
// | gender          | enum('secret','male','female','unknown') | YES  |     | secret  |                |
// | birthday        | date                                     | YES  |     | NULL    |                |
// | signature       | varchar(40)                              | YES  |     |         |                |
// | last_login_ip   | bigint(20) unsigned                      | YES  |     | 0       |                |
// | last_login_time | int(11) unsigned                         | YES  |     | 0       |                |
// | activation_key  | varchar(60)                              | YES  |     |         |                |
// | status          | tinyint(1)                               | YES  |     | 1       |                |
// | member_id       | int(11) unsigned                         | YES  |     | 0       |                |
// | create_time     | int(11) unsigned                         | YES  |     | 0       |                |
// | update_time     | int(11) unsigned                         | YES  |     | 0       |                |
// | delete_time     | int(11) unsigned                         | YES  |     | 0       |                |
// | college_name    | varchar(50)                              | YES  |     |         |                |
// | pro_title       | varchar(30)                              | YES  |     |         |                |
// +-----------------+------------------------------------------+------+-----+---------+----------------+
namespace app\common\validate;

use think\Validate;

class User extends Validate
{
    protected $rule = [
        "id" => "gt:0",
        "name" => "min:2|max:30|unique:user",
        "nickname" => "min:2|max:30",
        "email" => "email|max:50|unique:user",
        "mobile" => "max:20|unique:user",
        "gender" => "require",
        "birthday" => "require|after:1900-01-01",
        "college_name" => "min:4|max:15",
        "pro_title" => "min:2|max:15",
        "password" => "confirm:confirm_password|length:6,20",
        "url" => "url",
    ];

    protected $field = [
        "id" => "管理员ID",
        "name"  => "登录名",
        "nickname"  => "真实姓名",
        "email"  => "注册邮箱",
        "mobile"  => "手机号码",
        "password"  => "登录密码",
        "url" => "url",
    ];

    protected $message = [
        "id.gt" => "用户ID不能为空",
        "name.min" => "登录名长度必须在2-30个字符之间",
        "name.max" => "登录名长度必须在2-30个字符之间",
        "name.name" => "当前登录名已注册",
        "nickname.min" => "用户昵称长度必须在2-30个字符之间",
        "nickname.max" => "用户昵称长度必须在2-30个字符之间",
        "birthday.require" => "出生年月不能为空",
        "birthday.before" => "请输入真实的出生年月日期",
        "birthday.after" => "请输入真实的出生年月日期",
        "email.email" => "注册邮箱格式不正确",
        "email.max" => "注册邮箱长度不能超过50个字符",
        "email.unique" => "当前邮箱已注册",
        "mobile.gt" => "手机号码格式不正确",
        "mobile.lt" => "手机号码格式不正确",
        "mobile.unique" => "当前手机号码已注册",
        "password.confirm" => "两次输入的密码不一致",
        "password.length" => "登录密码长度必须在6-20之间",
        "college_name.min" => "学校名长度必须在4-15个字符之间",
        "college_name.max" => "学校名长度必须在4-15个字符之间",
        "pro_title.min" => "职称名长度必须在2-15个字符之间",
        "pro_title.max" => "职称名长度必须在2-15个字符之间",
        "url" => "url格式不正确",
    ];

    protected $scene = [
        'create'  =>  ['name','mobile', 'password'],
        'update'  =>  ['name','mobile', 'password'],
        'update_detail'  =>  ['email', 'gender', 'birthday', 'college_name', 'pro_title'],
        'change_password'  =>  ['password'],
    ];
}